//
//  JL_EntityToJsonTool.m
//  flutter_jl_bluetooth_plugin
//
//  Created by 凌煊峰 on 2021/7/26.
//

#import "JL_EntityToJsonTool.h"

@implementation JL_EntityToJsonTool

//firstBle.mPeripheral     = JL_ug.bt_Entity.mPeripheral;
//firstBle.mItem           = JL_ug.bt_Entity.mPeripheral.name;
//firstBle.isSelectedStatus= YES;
//firstBle.mIndex          = 0;

//CB_EXTERN_CLASS @interface CBPeripheral : CBPeer
//@property(retain, readonly, nullable) NSString *name;
//@property(retain, readonly, nullable) NSNumber *RSSI NS_DEPRECATED(10_7, 10_13, 5_0, 8_0);
//@property(readonly) CBPeripheralState state;

//typedef NS_ENUM(NSInteger, CBPeripheralState) {
//    CBPeripheralStateDisconnected = 0,
//    CBPeripheralStateConnecting,
//    CBPeripheralStateConnected,
//    CBPeripheralStateDisconnecting NS_AVAILABLE(10_13, 9_0),
//} NS_AVAILABLE(10_9, 7_0);

+ (NSArray<NSDictionary *> *)arrayFromJLEntityList:(NSArray<DeviceEntity *> *)btEnityList {
    NSMutableArray<NSDictionary *> *arr = [NSMutableArray array];
    for (DeviceEntity *entity in btEnityList) {
        NSMutableDictionary *mPeripheralDict = [NSMutableDictionary dictionary];
        [mPeripheralDict setObject:entity.mName forKey:@"name"];
        [mPeripheralDict setObject:[entity.mPeripheral.identifier UUIDString] forKey:@"identifier"];
        [mPeripheralDict setObject:[NSNumber numberWithInteger:entity.mPeripheral.state] forKey:@"state"];
        [arr addObject:mPeripheralDict];
    }
    return arr;
}

@end
